import numpy as np


# 标准化归一化处理
# 正指标 = (x-min)/(max-min)
# 负指标 = (max-x)/(max-min)
def normalizing(dataframe):
    for column in list(dataframe.columns):
        # 获取各个指标的最大值和最小值
        max_val = np.max(dataframe[column])
        min_val = np.min(dataframe[column])
        if '负指标' in column:
            dataframe[column] = (max_val - dataframe[column]) / (max_val - min_val)
        else:
            dataframe[column] = (dataframe[column] - min_val) / (max_val - min_val)

    print('-----------归一化处理-----------')
    print(dataframe)

    return dataframe
